<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Sort LDAP result entries on the client side</title>
 </head>
 <body class="docs"><div id="layout">
  <div id="layout-content"><div id="function.ldap-sort" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">ldap_sort</h1>
  <p class="verinfo">(PHP 4 &gt;= 4.2.0, PHP 5, PHP 7)</p><p class="refpurpose"><span class="refname">ldap_sort</span> &mdash; <span class="dc-title">Sort LDAP result entries on the client side</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.ldap-sort-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>ldap_sort</strong></span>
    ( <span class="methodparam"><span class="type">resource</span> <code class="parameter">$link</code></span>
   , <span class="methodparam"><span class="type">resource</span> <code class="parameter">$result</code></span>
   , <span class="methodparam"><span class="type">string</span> <code class="parameter">$sortfilter</code></span>
   ) : <span class="type">bool</span></div>

  <p class="para rdfs-comment">
   Sort the result of a LDAP search, returned by
   <span class="function"><a href="ldap_search.html" class="function">ldap_search()</a></span>.
  </p>
  <p class="para">
   As this function sorts the returned values on the client side it is possible that 
   you might not get the expected results in case you reach the <code class="parameter">sizelimit</code> either of the server or
   defined within <span class="function"><a href="ldap_search.html" class="function">ldap_search()</a></span>.
  </p>
  <div class="warning"><strong class="warning">Warning</strong><p class="simpara">This feature has been
<em class="emphasis">DEPRECATED</em> as of PHP 7.0.0. Relying on this feature
is highly discouraged.</p></div>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.ldap-sort-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    
     <dt>
<code class="parameter">link</code></dt>

     <dd>

      <p class="para">
       An LDAP link identifier, returned by <span class="function"><a href="ldap_connect.html" class="function">ldap_connect()</a></span>.
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">result</code></dt>

     <dd>

      <p class="para">
       An search result identifier, returned by
       <span class="function"><a href="ldap_search.html" class="function">ldap_search()</a></span>.
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">sortfilter</code></dt>

     <dd>

      <p class="para">
       The attribute to use as a key in the sort.
      </p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.ldap-sort-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   Sorting the result of a search.
   <div class="example" id="example-5412">
    <p><strong>Example #1 LDAP sort</strong></p>
    <div class="example-contents">
     <div class="phpcode"><pre><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;$ds&nbsp;is&nbsp;a&nbsp;valid&nbsp;link&nbsp;identifier&nbsp;(see&nbsp;ldap_connect)<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$dn&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">'ou=example,dc=org'</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$filter&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">'(|(sn=Doe*)(givenname=John*))'</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$justthese&nbsp;</span><span style="color: #007700">=&nbsp;array(</span><span style="color: #DD0000">'ou'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'sn'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'givenname'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'mail'</span><span style="color: #007700">);<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$sr&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">ldap_search</span><span style="color: #007700">(</span><span style="color: #0000BB">$ds</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$dn</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$filter</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$justthese</span><span style="color: #007700">);<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;Sort<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">ldap_sort</span><span style="color: #007700">(</span><span style="color: #0000BB">$ds</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$sr</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'sn'</span><span style="color: #007700">);<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;Retrieving&nbsp;the&nbsp;data<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$info&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">ldap_get_entries</span><span style="color: #007700">(</span><span style="color: #0000BB">$ds</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$sr</span><span style="color: #007700">);</span>
</span>
</pre></div>
    </div>

   </div>
  </p>
 </div>

</div></div></div></body></html>